const REG_EXP = {
  EMPTY: /^\S+$/,
  PHONE: /^(0|86|17951)?(1[356789])[0-9]{9}$/,
  CHINESE: /^[\u4e00-\u9fa5]{2,4}$/,
  ID_CARD: /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/,
}

export const validate = function(pattern){
  return function(val){
    return pattern.test(val)
  }
}

export const isPhone = validate(REG_EXP.PHONE)
export const isEmpty = validate(REG_EXP.EMPTY)
export const isChinese = validate(REG_EXP.CHINESE)
export const isIdCard = validate(REG_EXP.ID_CARD)